import { createContext } from "react";
import type { TaskProps, TaskMode, FlattenedTask } from "./types";
import type { Dayjs } from "dayjs";

export interface GanttContextProps {
  tasks: TaskProps[];
  tasksStart: Dayjs;
  tasksEnd: Dayjs;
  setTasks: (tasks: TaskProps[]) => void;
  flattenedTasks: FlattenedTask[];
  setFlattenedTasks: (tasks: FlattenedTask[]) => void;
  expandedTasks: Set<string>;
  setExpandedTasks: (expanded: Set<string>) => void;
  taskMode: TaskMode;
  setTaskMode: (taskMode: TaskMode) => void;
  hideTask: boolean;
  setHideTask: (hideTask: boolean) => void;
  toggleExpand: (taskId: string) => void;
  hoverTaskId: string;
  setHoverTaskId: (taskId: string) => void;
  // 垂直滚动同步状态
  scrollTop: number;
  setScrollTop: (scrollTop: number) => void;
  // 水平滚动同步状态
  scrollLeft: number;
  setScrollLeft: (scrollLeft: number) => void;
  containerHeight: number;
  containerWidth: number;
  totalWidth: number;
  setTotalWidth: (totalWidth: number) => void;
  // 水平滚动
  hScrollbarWidth: number;
  setHScrollbarWidth: (hScrollbarWidth: number) => void;
  hScrollbarLeft: number;
  setHScrollbarLeft: (hScrollbarLeft: number) => void;
  // 垂直滚动
  vScrollbarHeight: number;
  setVScrollbarHeight: (vScrollbarHeight: number) => void;
  vScrollbarTop: number;
  setVScrollbarTop: (vScrollbarTop: number) => void;
}

const GanttContext = createContext<GanttContextProps>({} as GanttContextProps);

export default GanttContext;
